<?php
namespace app\index\controller;
/**
 * Created by Submint Text.
 * User: hetaoren<452649510@qq.com>
 * Date: 2017/03/10
 * Explain: 积分日志控制器
 */
class Integrallog extends Base{
   /**
	* 查看库存列表
	*/
	public function index(){        
        $user_id = input('user_id/d',0);
        if($user_id){
            session('user_id', $user_id);
        }else{
            session('user_id', null);
        }
        $time1 = strtotime('2017-10'); 
        $monarr = []; 
        while(($time1 = strtotime('+1 month', $time1)) <= time()){  
              $monarr[] = date('Y-m',$time1); // 取得递增月;   
        }    
        $this->assign("monarr",$monarr);
		return $this->fetch();
	}
    /**
     * 获取分页
     */
    public function pageQuery(){
        return model('IntegralLog')->pageQuery();
    }
    /**
     * 编辑
     */
    public function upIntegral(){   
        $user_id = input('user_id/d',0);
        $type = input('type/d',0);
        $num = input('num/d',0);
        $desc = input('desc','');
        if($num < 1)return HTRReturn("数量不正确");
        if($desc == '')return HTRReturn("描述不能为空");
        return model('IntegralLog')->add($user_id,$type,$num,$desc);
    }
}
